from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter

from django.urls import re_path
from k8s_api.websocket.container_terminal import StreamConsumer
from k8s_api.websocket.container_logs import StreamLogConsumer

application = ProtocolTypeRouter({
    'websocket': AuthMiddlewareStack(
        URLRouter([
            re_path(r'^workload/container_terminal/(?P<namespace>.*)/(?P<pod_name>.*)/(?P<container>.*)/', StreamConsumer.as_asgi()),
            re_path(r'^workload/container_logs/(?P<namespace>.*)/(?P<pod_name>.*)/(?P<container>.*)/', StreamLogConsumer.as_asgi()),
        ])
    ),
})